/*
  (C) 2005 Adam D. Bradley

  This program is free software; you can redistribute it and/or
  modify it under the terms of Version 2 of the GNU General Public 
  License.
  
  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  General Public License for more details.
  
  You should have received a copy of the GNU Library General Public
  License along with this library; if not, write to the Free
  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

package step;

import java.net.URI;
import java.util.ArrayList;

import step.ReceiverSocketNode;
import step.exceptions.STEPException;

/**
 * A ReceiverUdpSocketNode is where data enters the local STEP from a remote
 * STEP via the (unreliable) UDP datagram protocol.  We use a thread and
 * a toy retransmission mechanism.  This is not meant to be practical,
 * but rather is an illustration of how to build non-HTTP interface
 * protocol nodes.
 */
public class ReceiverUdpSocketNode extends ReceiverSocketNode
{
	public ReceiverUdpSocketNode(String id, String fromID, URI fromURI) {
		super(id, fromID, fromURI);
	}

	public ReceiverUdpSocketNode(String fromID, URI fromURI) {
		super(fromID, fromURI);
	}

	public String GetInfoXML() { 
		return super.GetInfoXML("UDP", "receiver", FromURI); 
	}
	
	protected void Bind() throws java.lang.ClassNotFoundException /* DOME */ {
		assert(false);
		super.Bind();
	}

	public boolean IsEnabled() { 
		return false;
	}

	public void Evaluate() throws EvaluationFailure {
		throw new EvaluationFailure(this, "This node is never enabled!");
	}

	public void Write(java.io.OutputStream out, int depth) throws java.io.IOException {
		WriteBasis(out, depth, "type=\"receiver\" method=\"post\"");
	}

	@Override
	public void validate(Graph g, ArrayList<STEPException> compilationErrors) {
		// TODO Auto-generated method stub
	}
	
	@Override
	public Node ShallowCopy() {
		ReceiverUdpSocketNode cn = new ReceiverUdpSocketNode(ID, FromID, FromURI);
		Node.CopyNonRTPropertiesFromAtoB(this,cn);
		return cn;
	}
}

